package rpg.oop;

import java.util.ArrayList;

import static rpg.oop.RPG.randomGenerator;

public class GoldShop extends Player {
    public static int gold;              // 金币
    public static int reputation;        // 声望
    String goods;                 // 道具
    Creature a = new Creature();

    /**
     * 获得金币
     *
     * @param enemy 被玩家杀死的敌人
     * @return 增长的金币
     */
    public static int getGold(Creature enemy) {
        int baseGold = 2;
        int randomGold = randomGenerator.nextInt(0, 10);
        int getGolds = enemy.level * (baseGold + randomGold);
        gold += getGolds;
        return getGolds;
    }

    /**
     * 获得声望
     *
     * @param enemy 被玩家杀死的敌人
     * @return 增长的声望
     */
    public static int getReputation(Creature enemy) {
        int baseReputation = 0;
        int randomReputation = randomGenerator.nextInt(0, 5);
        int getReputations = enemy.level * (baseReputation + randomReputation);
        reputation += getReputations;
        return getReputations;
    }

    /**
     * 商店道具
     */
    public void buyGoods() {
        int attackMaxIncrease = 0;
        int hpMaxIncrease = 0;
        switch (goods) {
            case "九阳神功":
                if (gold >= 35) {
                    hpMaxIncrease = 10;
                    gold -= 35;
                    goods = "九阳神功";
                }else{System.out.println("余额不足");}
                break;
            case "九阴白骨爪":
                if (gold >= 35) {
                    attackMaxIncrease = 9;
                    gold -= 35;
                    goods = "九阴白骨爪";
                }else{System.out.println("余额不足");}
                break;
            case "铁剑":
                if (gold >= 10) {
                    attackMaxIncrease = 10;
                    gold -= 10;
                    goods = "铁剑";
                }else{System.out.println("余额不足");}
                break;
            case "精钢剑":
                if (gold >= 20) {
                    attackMaxIncrease = 17;
                    gold -= 20;
                    goods = "精钢剑";
                }else{System.out.println("余额不足");}
                break;
            case "柴刀":
                if (gold >= 10) {
                    attackMaxIncrease = 11;
                    gold -= 10;
                    goods = "柴刀";
                }else{System.out.println("余额不足");}
                break;
            case "百炼刀":
                if (gold >= 20) {
                    attackMaxIncrease = 16;
                    gold -= 20;
                    goods = "百炼刀";
                }else{System.out.println("余额不足");}
                break;
            case "炼毒罐":
                if (gold >= 10) {
                    attackMaxIncrease = 12;
                    gold -= 10;
                    goods = "炼毒罐";
                }else{System.out.println("余额不足");}
                break;
            case "青铜鼎":
                if (gold >= 20) {
                    attackMaxIncrease = 15;
                    gold -= 20;
                    goods = "青铜鼎";
                }else{System.out.println("余额不足");}
                break;
            case "伸腿瞪眼丸":
                if (gold >= 10) {
                    hpPotions++;
                    gold -= 10;
                    goods = "伸腿瞪眼丸";
                }else{System.out.println("余额不足");}
                break;
        }
        maxHp = randomGenerator.nextInt(1, 6) + curHp;
        curHp = maxHp;
        maxAtt += randomGenerator.nextInt(0, attackMaxIncrease);
        minAtt = maxAtt - 3;
    }

    public  static ArrayList<String> shopList() {
        ArrayList<String> list = new ArrayList<>();
        list.add("九阳神功  35金币");
        list.add("九阴白骨爪  35金币");
        list.add("铁剑  10金币");
        list.add("精钢剑  20金币");
        list.add("柴刀  10金币");
        list.add("百炼刀  20金币");
        list.add("炼毒罐  10金币");
        list.add("青铜鼎  20金币");
        list.add("伸腿瞪眼丸  10金币");
        return list;
    }

    /**
     * 武器使用与卸下
     */
  /*  public void useGoods() {
        int attackMaxIncrease = 0;
        int hpMaxIncrease = 0;
        switch (goods) {
            case "使用九阳神功":
                hpMaxIncrease = 10;
                break;
            case "使用九阴白骨爪":
                attackMaxIncrease = 9;
                break;
            case "使用铁剑":
                attackMaxIncrease = 10;
                break;
            case "使用精钢剑":
                attackMaxIncrease = 17;
                break;
            case "使用柴刀":
                attackMaxIncrease = 11;
                break;
            case "使用百炼刀":
                attackMaxIncrease = 16;
                break;
            case "使用炼毒罐":
                attackMaxIncrease = 12;
                break;
            case "使用青铜鼎":
                attackMaxIncrease = 15;
                break;
            case "卸下铁剑":
                attackMaxIncrease = -10;
                break;
            case "卸下精钢剑":
                attackMaxIncrease = -17;
                break;
            case "卸下柴刀":
                attackMaxIncrease = -11;
                break;
            case "卸下百炼刀":
                attackMaxIncrease = -16;
                break;
            case "卸下炼毒罐":
                attackMaxIncrease = -12;
                break;
            case "卸下青铜鼎":
                attackMaxIncrease = -15;
                break;
        }
        maxHp = randomGenerator.nextInt(1, 6) + curHp;
        curHp = maxHp;
        maxAtt += randomGenerator.nextInt(0, attackMaxIncrease);
        minAtt = maxAtt - 3;
    }*/

    /**
     * 复活
     */
    public  void resurgence() {
        if (reputation >= 100) {
            reputation -= 100;
            initialize(a);
            for (int i = 0; i < saveLever; i++) {
                int hpMaxIncrease = 0;
                int attackMaxIncrease = 0;
                switch (role) {
                    case "刀客":
                        hpMaxIncrease = 14;
                        attackMaxIncrease = 12;
                        break;
                    case "剑客":
                        hpMaxIncrease = 13;
                        attackMaxIncrease = 13;
                        break;
                    case "毒师":
                        hpMaxIncrease = 10;
                        attackMaxIncrease = 15;
                        break;

                }
                maxHp += randomGenerator.nextInt(0, hpMaxIncrease);
                maxAtt += randomGenerator.nextInt(0, attackMaxIncrease);
                minAtt = maxAtt - 3;
                curHp = maxHp;
            }
        }

    }
}
